<!DOCTYPE html>
<html>
<head>
    <title>仓库管理系统</title>
    <script>
        async function loadProducts() {
            const response = await fetch('http://localhost:3000/products');
            const products = await response.json();
            const list = document.getElementById('product-list');
            list.innerHTML = products.map(p => 
                `<li>${p.name} (库存: ${p.quantity || 0})</li>`
            ).join('');
        }
        
        async function addProduct() {
            const name = prompt('输入商品名称');
            if(name) {
                await fetch('http://localhost:3000/products', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ name })
                });
                loadProducts();
            }
        }
    </script>
</head>
<body onload="loadProducts()">
    <h1>仓库管理系统</h1>
    <button onclick="addProduct()">添加商品</button>
    <ul id="product-list"></ul>
</body>
</html>